# -*- coding: utf-8 -*-
from threads import TaskThread


class SchedulerDemo:
    def __init__(self):
        self.thread_list = []

    def start(self, widget, callback):
        for row_index in range(widget.ui.tableWidget.rowCount()):
            asin = widget.ui.tableWidget.item(row_index, 0).text()
            status = widget.ui.tableWidget.item(row_index, 6).text()

            if status != "待执行":
                continue

            self.taskThread = TaskThread(row_index, asin, widget)
            self.taskThread.start_signal.connect(callback)
            self.taskThread.start()

    def stop(self):
        pass


# 单例模式
scheduler = SchedulerDemo()
